﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EFWCoreLib.CoreFrame.Business.AttributeInfo;
using EFWCoreLib.WcfFrame.ServerController;
using Books.Entity;
using System.Data;
using Books.Dao;
using EFWCoreLib.WcfFrame.DataSerialize;
using EFWCoreLib.WcfFrame.ServerManage;

namespace Books.WcfController
{
    [WCFController]
    public class BookDemoService : WcfServerController
    {
        [WCFMethod]
        public ServiceResponseData SaveBook()
        {
            Book book = requestData.GetData<Book>(0);
            BindDb(book);
            book.save();
            responseData.AddData(true);
            return responseData;
        }

        [WCFMethod]
        public ServiceResponseData GetBooks()
        {
            //List<Books> list = oleDb.Query<Books>(@"select * from BOOKS t", null).ToList();
            List<Book> list = NewDao<SqlBookDao>().GetBooks("", 0);
            responseData.AddData(list);
            return responseData;
        }

        [WCFMethod]
        public ServiceResponseData DeleteBook()
        {
            int Id = requestData.GetData<int>(0);
            NewObject<Book>().delete(Id);
            responseData.AddData(true);
            return responseData;
        }
    }
}

